#include "mainwidget.h"

MainWidget::MainWidget()
{
    setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
    createWidgets();
}

// Create widgets.
void MainWidget::createWidgets()
{
    // TODO.

    QSplitter* split = new QSplitter(Qt::Horizontal);
    hLayout = new QHBoxLayout();
    barAndGrid = new QVBoxLayout();
    barAndGrid->setContentsMargins(0,0,0,0);
    QWidget* barAndGridWidget = new QWidget();
    theBar = new BarWidget();
    theOrganizer = OrganizerWidget::getInstance();
    theGrid = GridWidget::getInstance();

    theOrganizer->setGeometry(QRect(0,0,100,900));

    QScrollArea* scroll = new QScrollArea();
    scroll->setFrameStyle(QFrame::NoFrame);
    scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    scroll->setWidgetResizable(true);
    scroll->setWidget(theGrid);
    scroll->setAlignment(Qt::AlignTop);

    barAndGrid->addSpacing(18);
    barAndGrid->addWidget(theBar,0,Qt::AlignTop);
    barAndGrid->addWidget(scroll);

    split->addWidget(theOrganizer);
    barAndGridWidget->setLayout(barAndGrid);
    barAndGridWidget->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding);
    split->addWidget(barAndGridWidget);
    split->setStyle(new QPlastiqueStyle);
    split->setMinimumWidth(200);
    split->setMaximumWidth(600);


    hLayout->addWidget(split);
    setLayout(hLayout);
}
